package com.kaifamiao.month05.day17;

import org.junit.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class Demo {

    @Test
    public void a() {
        System.out.println("测试");
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            String url = "jdbc:oracle:thin:@localhost:1521/xe";
            String user = "root";
            String pass = "root";
            Connection conn = DriverManager.getConnection(url,user,pass);
            Statement sta = conn.createStatement();
            String sql = "insert into users(id,name,pass,birth) values(1,'张三','123456',sysdate)";
            int num = sta.executeUpdate(sql);
            if (num > 0) {
                System.out.println("创建成功！");
                System.out.println(num + "条记录被修改");
            } else {
                System.out.println("创建失败！");
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
}
